package com.chd.driversystem;

import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;

import com.chd.driversystem.domain.User;
import com.chd.driversystem.util.network.HttpManager;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

import static org.junit.Assert.*;

/**
 * Instrumentation test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {

    private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    private static final String TAG = "ExampleInstrumentedTest";

    @Test
    public void useAppContext() throws Exception {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getTargetContext();

        assertEquals("com.chd.driversystem", appContext.getPackageName());
    }

    @Test
    public void NetUserlistTest() throws IOException {
        List<User> userList = HttpManager.getUserList(1L);
        Log.d(TAG, "NetTest: "+userList);
        Log.d(TAG, "NetTest err: "+HttpManager.getErrorCode()+HttpManager.getErrorMsg());
    }

    @Test
    public void NetDriverDateDataTest() throws IOException, ParseException {
//        DateData dateData =
//                HttpManager.getDriverDataByDateRange("1311120350", dateFormat.parse("2014-04-1"),
//                dateFormat.parse("2017-11-1"));
//        List<AccDec> accDecs = dateData.getDayAccDec();
//        List<Mile> miles = dateData.getDayMile();
//        List<NetOil> netOils = dateData.getDayOil();
//        List<ShiftBreak>shiftBreaks=dateData.getDaySwitchBreak();
//
//        Log.d(TAG, "NetTest err: "+HttpManager.getErrorCode()+HttpManager.getErrorMsg());
//        Log.d(TAG, "4 size: :  "+accDecs.size()+"  "+miles.size()+"  "+netOils.size() +"  "+shiftBreaks.size());
//        Assert.assertNotNull(dateData);
    }
}
